package org.shreker.shan.core.util;

import javax.servlet.http.HttpSession;
import org.shreker.shan.core.domain.Login;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public class LoginContext {

	public static HttpSession getSession() {
		ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		return requestAttributes.getRequest().getSession();
	}

	public static void setCurrentLogin(Login login) {
		getSession().setAttribute(Constant.LOGIN_IN_SESSION, login);
	}

	public static Login getCurrentLogin() {
		return (Login) getSession().getAttribute(Constant.LOGIN_IN_SESSION);
	}
	
	public static void removeCurrentLogin() {
		getSession().removeAttribute(Constant.LOGIN_IN_SESSION);
	}

}
